package com.ybkj.o2o.zhuanche.manager;


import com.ybkj.o2o.zhuanche.common.CompanyOrderVo;
import com.ybkj.o2o.zhuanche.common.DataGrid;
import com.ybkj.o2o.zhuanche.common.DriverOrderDetailVo;
import com.ybkj.o2o.zhuanche.common.DriverOrderVo;
import com.ybkj.o2o.zhuanche.common.MemberOrderVo;
import com.ybkj.o2o.zhuanche.common.OrderFromSourceVo;
import com.ybkj.o2o.zhuanche.common.PageVo;
import com.ybkj.o2o.zhuanche.common.query.OrderQuery;
import com.ybkj.o2o.zhuanche.controller.v4.Error;
import com.ybkj.o2o.zhuanche.controller.v4.ResultTransport;
import com.ybkj.o2o.zhuanche.entity.ChartDay;
import com.ybkj.o2o.zhuanche.entity.ChartMonth;
import com.ybkj.o2o.zhuanche.entity.ChartYear;
import com.ybkj.o2o.zhuanche.entity.Order;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;


public interface OrderManager {

  /**
   * 返回订单基本数据.
   */
  Order queryOneOrder(Long orderId, String appKey);
  
  Order findByIdAndAppKey(Long orderId, String appKey);

  /**
   * 根据查询对象分页查询订单.
   */
  DataGrid<Order> findByParams(OrderQuery orderQuery);
  
  /**
   * 根据查询对象分页查询预约订单.
   */
  DataGrid<Order> findByParamsInBook(OrderQuery orderQuery);
  
  /**
   * 根据查询对象分页查询预约订单.
   */
  Long countByParamsInBook(OrderQuery orderQuery);
  
  /**
   * 后台专用列表查询接口.
   */
  
  DataGrid<Order> queryOrders(OrderQuery orderQuery);

    /**
     * 通过司机工号查询完成单量
     * @param orderQuery
     * @return
     */
    Long orderCountByEmployId(OrderQuery orderQuery);
  
  /**
   * 查询导出数据.
   */
  
  DataGrid<Order> exportOrders(OrderQuery orderQuery);
  
  /**
   * 保存专车订单.
   */
  Order insert(Long companyId, String companyName, Long passengerId, String passengerName,
      String passengerPhone, String showPhone, Long carTypeId, String channelName,
      String startAddress, String startAddressDetail, Double startLat, Double startLng,
      String endAddress, String endAddressDetail, Double endLat, Double endLng, Date serverDate,
      Double prestartPrice, Double premileagePrice, Double prerunTimePrice, Double budgetPay,
      Long couponId, Integer pretravelTime, Double premileage, String operator,
      String createOrderName, String appKey);

  Order tempToForever(String prePayTypeDetail, Long companyId, String companyName,
      Long passengerId, String passengerName, String passengerPhone, String showPhone,
      Long carTypeId, String channelName, String startAddress, String startAddressDetail,
      Double startLat, Double startLng, String endAddress, String endAddressDetail, Double endLat,
      Double endLng, Date serverDate, Double prestartPrice, Double premileagePrice,
      Double prerunTimePrice, Double budgetPay, Long couponId, Double shouldPay,
      Integer pretravelTime, Double premileage, String appKey);


  /**
   * 修改订单状态.
   */
  
  int updateStatus(Long orderId, Long employId, String employName, String employPhone,
      Long employCompanyId, String employNo, String employPhoto, Double employScore,
      Long rentalCompanyId, String rentalCompanyName,String action,
      String operator, String cancelCause, String appKey);

  int update(Order order);

  List<Order> findByEmployId(OrderQuery orderQuery);
  
  ChartYear dataForYear(Integer year, Long companyId, String appKey);

  ChartMonth dataForMonth(Integer year, Long companyId, Integer month, String appKey);

  ChartDay dataForDay(Integer year, Integer month, Integer day, Long companyId, String appKey);

  PageVo<OrderFromSourceVo> orderFromSource(Date date1, Date date2, Long companyId, String appKey);

  List<Order> findHastenOrderAppKey(String appKey);

  Order findFinishedByDriverWithDate(Long employId, Date start, Date end, String appKey);

  PageVo<DriverOrderVo> driverAchievement(
      Date date1, Date date2, Long empCompanyId, String appKey);

  PageVo<CompanyOrderVo> companyOrder(Date date1, Date date2, String appKey);

  List<Order> findMonthOrder(Integer year, Integer month, String appKey);

  PageVo<MemberOrderVo> findMemberOrder(
      Date startTime, Date endTime, Long companyId, String appKey);

  // 确认订单结算数据
  Order complete(Long orderId, Double realPay, Double guoluMoney, Double yuanchengMoney,
      Double otherMoney, Double startPrice, Double mileagePrice, Double runTimePrice,
      Double waitPrice, String endAddress, Double endLat, Double endLng, Double mileage,
      Integer midwayWait, Integer runTime, Double couponMoney, String appKey,
      String prePayTypeDetail, String memo,Double justKilometres,BigDecimal justMoney,
      Double ksMileage, Double ddMileage);

  // 结算订单
  Order finishTask(Long orderId, String afterPayTypeDetail, Double companyProfit,
      Double employProfit, Double signMoney, Double balanceMoney, Double alipayMoney,
      Double weixinMoney, Double unionpayMoney,
      Double cashMoney, String appKey, String operating, String endAddress,
      Double endLat, Double endLng, Integer runTime, Double mileage, Integer midwayWait,
      Double realPay, Double guoluMoney, Double baoxiaoMoney, String baoxiaoMemo, Long finishTime);

  // 司机补单
  Order addmore(Long passengerId, String passengerName, String passengerPhone, Long companyId,
      String companyName, Long carTypeId, String channelName, String startAddress, Double startLat,
      Double startLng, Date serverDate, Long employId, String employName, String employPhone,
      Long employCompanyId, String employNo, String employPhoto, Double employScore, String memo,
      String appKey);

  PageVo<DriverOrderDetailVo> driverOrderDetailVo(Long driverId, Date start, Date end,
      Integer page, Integer rows, String appKey);

  Map<String, Object> chart(Long companyId, Long startTime, Long endTime, Boolean maincompany,
      String appKey);

  // 统计条数
  Long countByParam(OrderQuery orderQuery);

  Order findLastOrder(OrderQuery orderQuery);

  void cancelOrder(Long orderId, String operator, Integer breaker, String cause, String appKey);

  Long queryRunOrder(OrderQuery orderQuery);

  void updateRealMoney(Long orderId, Double couponMoney, Double cashMoney, Double signMoney,
      Double balanceMoney, Double alipayMoney, Double weixinMoney, String operator, String content,
      String appKey);
  /**
   * V4接单.
   */
  
  Error jiedan(Long orderId, String appKey);

  /**
   * V4拒单.
   */
  
  Error refuse(Long orderId, Long employId, String cause, String operator, String appKey);

  /**
   * V4开始等待.
   */
  
  Error waitV4(Long orderId, String operator, String appKey);

  /**
   * V4开始执行订单.
   */
  
  Error runV4(Long orderId, String operator, String appKey,
      String realStartAddress,Double realStartLat,Double realStartLng);

  /**
   * V4抢单.
   */
  
  Error grab(Long orderId, Long employId, String employName, String employPhone,
      Long employCompanyId, String employNo, String employPhoto, Double employScore,
      Long rentalCompanyId, String rentalCompanyName, String operator, String appKey);

  /**
   * V4司机端销单.
   */
  
  Error cancelV4(Long orderId, String cause, String appKey);

  /**
   * 员工奖励相关接口.
   */
  
  List<Order> findOrderByEmployId(OrderQuery orderQuery);

  /**
   * V4报销金额.
   */
  
  void baoxiao(Long orderId, Double baoxiaoMoney, String appKey);

  void cancelByEmployee(Long orderId, String cause, String appKey);
  
  /**
   * 保存订单V4up.
   */
  
  ResultTransport createV4up(Long passengerId, String passengerName, String passengerPhone,
      String userPhone,int passengerGender,Long companyId, String companyName, String channelName, Date serverDate,
      String startAddress, String startAddressDetail, Double startLat, Double startLng,
      String endAddress, String endAddressDetail, Double endLat, Double endLng, Boolean prePay,
      Integer travelTime, Double mileage, String memo, String flightNo, String trainNo,
      String operator, Long serviceTypeId, String serviceType, String carTypes, String couponIds,
      String serverUrl, Double couponMoney, String createOrderName, String useType, String appKey,
      Integer bookStatus,BigDecimal makePrice,Integer isMakePrice,Long driverId);

  List<Order> queryByGroupId(OrderQuery orderQuery);

  Order tempToForeverV4up(String prePayTypeDetail, Long companyId, String companyName,
      Long passengerId, String passengerName, String passengerPhone, String showPhone,
      Long carTypeId, String channelName, String startAddress, String startAddressDetail,
      Double startLat, Double startLng, String endAddress, String endAddressDetail, Double endLat,
      Double endLng, Date serverDate, Double prestartPrice, Double premileagePrice,
      Double prerunTimePrice, Double budgetPay, Long couponId, Long employId, Double shouldPay,
      Integer pretravelTime, Double premileage, String memo, String flightNo, String trainNo,
      Long serviceTypeId, Long areaId, String serverUrl, String appKey);

  DataGrid<Map<String, Object>> findOrdersV4up(OrderQuery orderQuery);

  Map<String, Object> findByIdAndAppKeyV4up(Long orderId, String appKey);

  ResultTransport createMoreV4up(Long passengerId, String passengerName, String passengerPhone,
      Long companyId, String companyName, String orderTypeBudan, Date serverDate,
      String startAddress, Double startLat, Double startLng, String endAddress, Double endLat,
      Double endLng, Integer travelTime, Double mileage, Long areaId, Long employId,
      String employName,String employPhone, String employPhoto, String employNo,
      Long serviceTypeId, String flightNo, String trainNo, Double budgetPay, Double prestartPrice,
      Double premileagePrice, Double prerunTimePrice, Boolean inBlackList,
      Long rentalCompanyId, String rentalCompanyName, String serverUrl, String appKey,
      Long voiceId,String voiceHttpPath);

  Long countRunningOrder(Long carTypeId, String appKey);

  Map<String, Object> findOneV4up(Long id, String appKey);

  Boolean checkExist(Long orderId, String appKey);

  DataGrid<Order> queryFinishOrder(OrderQuery orderQuery);
  
  DataGrid<Order> selectFinishOrder(OrderQuery orderQuery);

  Boolean prepare(Long orderId, String appKey);

  int autoPaidan(Long orderId, Long employId, String employName, String employPhone,
      Long employCompanyId, String employNo, String employPhoto, Double employScore,
      Long rentalCompanyId, String rentalCompanyName, String appKey);


  Long driverOrderDetailCount(OrderQuery orderQuery);

  Long countRunning(Long passengerId, String appKey);

  List<Map<String,Object>> countOrderNumByDriver(Long[] driverIds, Date start, Date end, String appKey);

  Map<String,Object> countOnDutyByDriver(Long driverId, Date start, Date end); 

  List<Map<String,Object>> countBookDriver(Long zhuanYuyueMax,Date zhuanYuyueTime,String appKey);
  
  List<Map<String,Object>> findDriverBusy(Long zhuanYuyueMax,Date zhuanYuyueTime,String appKey,Long employId);
   
  List<Map<String,Object>> countBusyBookDriver(Date zhuanYuyueTime,String appKey);
  
  Integer getTodayBooks(Long employId,Date start,Date end);
}
